"""
@Author  : 康帅
@Time    : 2021/3/17 13:48
@Function: 封装请假案列基类
"""
from abc import ABCMeta, abstractmethod


class Request:
    """ 请求(内容)"""

    def __init__(self, name, day_off, reason):
        self.__name = name
        self.__day_off = day_off
        self.__reason = reason
        self.__leader = None

    def get_name(self):
        return self.__name

    def get_day_off(self):
        return self.__day_off

    def get_reason(self):
        return self.__reason


class Responsible(metaclass=ABCMeta):
    """ 责任人抽象 """

    def __init__(self, name, title):
        self.__name = name
        self.__title = title
        self._next_handler = None

    def get_name(self):
        return self.__name

    def get_title(self):
        return self.__title

    def set_next_handler(self, next_handler):
        self._next_handler = next_handler

    def get_next_handler(self):
        return self._next_handler

    def handler_request(self, request):
        """ 请求处理 """

        # 当前责任人处理请求
        self._handler_request_impl(request)
        # 如果存在下一责任人，则将请求传递给下一个责任人
        if self._next_handler is not None:
            self._next_handler.handler_request(request)

    @abstractmethod
    def _handler_request_impl(self, request):
        """ 真正处理请求的方法 """
        pass
